package aigle.idm.diagraph.tp3.diagram_default_root.providers;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
import org.eclipse.gmf.runtime.common.core.service.IOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider;
import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter;
import org.eclipse.gmf.runtime.notation.View;

import aigle.idm.diagraph.tp3.Tp3Package;

/**
 * @generated
 */
public class Tp3ParserProvider extends AbstractProvider implements
		IParserProvider {

	/**
	 * @generated
	 */
	private IParser recetteNom_4002Parser;

	/**
	 * @generated
	 */
	private IParser getRecetteNom_4002Parser() {
		if (recetteNom_4002Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp3Package.eINSTANCE
					.getRecette_Nom() };
			aigle.idm.diagraph.tp3.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp3.diagram_default_root.parsers.MessageFormatParser(
					features);
			recetteNom_4002Parser = parser;
		}
		return recetteNom_4002Parser;
	}

	/**
	 * @generated
	 */
	private IParser ingredientName_4003Parser;

	/**
	 * @generated
	 */
	private IParser getIngredientName_4003Parser() {
		if (ingredientName_4003Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp3Package.eINSTANCE
					.getIngredient_Name() };
			aigle.idm.diagraph.tp3.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp3.diagram_default_root.parsers.MessageFormatParser(
					features);
			ingredientName_4003Parser = parser;
		}
		return ingredientName_4003Parser;
	}

	/**
	 * @generated
	 */
	private IParser vinNom_4004Parser;

	/**
	 * @generated
	 */
	private IParser getVinNom_4004Parser() {
		if (vinNom_4004Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp3Package.eINSTANCE
					.getVin_Nom() };
			aigle.idm.diagraph.tp3.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp3.diagram_default_root.parsers.MessageFormatParser(
					features);
			vinNom_4004Parser = parser;
		}
		return vinNom_4004Parser;
	}

	/**
	 * @generated
	 */
	private IParser localisationName_4005Parser;

	/**
	 * @generated
	 */
	private IParser getLocalisationName_4005Parser() {
		if (localisationName_4005Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp3Package.eINSTANCE
					.getLocalisation_Name() };
			aigle.idm.diagraph.tp3.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp3.diagram_default_root.parsers.MessageFormatParser(
					features);
			localisationName_4005Parser = parser;
		}
		return localisationName_4005Parser;
	}

	/**
	 * @generated
	 */
	private IParser bouteilleNom_4001Parser;

	/**
	 * @generated
	 */
	private IParser getBouteilleNom_4001Parser() {
		if (bouteilleNom_4001Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp3Package.eINSTANCE
					.getBouteille_Nom() };
			aigle.idm.diagraph.tp3.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp3.diagram_default_root.parsers.MessageFormatParser(
					features);
			bouteilleNom_4001Parser = parser;
		}
		return bouteilleNom_4001Parser;
	}

	/**
	 * @generated
	 */
	private IParser composeQuantite_4006Parser;

	/**
	 * @generated
	 */
	private IParser getComposeQuantite_4006Parser() {
		if (composeQuantite_4006Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp3Package.eINSTANCE
					.getCompose_Quantite() };
			aigle.idm.diagraph.tp3.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp3.diagram_default_root.parsers.MessageFormatParser(
					features);
			composeQuantite_4006Parser = parser;
		}
		return composeQuantite_4006Parser;
	}

	/**
	 * @generated
	 */
	protected IParser getParser(int visualID) {
		switch (visualID) {
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.RecetteNomEditPart.VISUAL_ID:
			return getRecetteNom_4002Parser();
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.IngredientNameEditPart.VISUAL_ID:
			return getIngredientName_4003Parser();
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.VinNomEditPart.VISUAL_ID:
			return getVinNom_4004Parser();
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.LocalisationNameEditPart.VISUAL_ID:
			return getLocalisationName_4005Parser();
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.BouteilleNomEditPart.VISUAL_ID:
			return getBouteilleNom_4001Parser();
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.ComposeQuantiteEditPart.VISUAL_ID:
			return getComposeQuantite_4006Parser();
		}
		return null;
	}

	/**
	 * Utility method that consults ParserService
	 * @generated
	 */
	public static IParser getParser(IElementType type, EObject object,
			String parserHint) {
		return ParserService.getInstance().getParser(
				new HintAdapter(type, object, parserHint));
	}

	/**
	 * @generated
	 */
	public IParser getParser(IAdaptable hint) {
		String vid = (String) hint.getAdapter(String.class);
		if (vid != null) {
			return getParser(aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3VisualIDRegistry
					.getVisualID(vid));
		}
		View view = (View) hint.getAdapter(View.class);
		if (view != null) {
			return getParser(aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3VisualIDRegistry
					.getVisualID(view));
		}
		return null;
	}

	/**
	 * @generated
	 */
	public boolean provides(IOperation operation) {
		if (operation instanceof GetParserOperation) {
			IAdaptable hint = ((GetParserOperation) operation).getHint();
			if (aigle.idm.diagraph.tp3.diagram_default_root.providers.Tp3ElementTypes
					.getElement(hint) == null) {
				return false;
			}
			return getParser(hint) != null;
		}
		return false;
	}

	/**
	 * @generated
	 */
	private static class HintAdapter extends ParserHintAdapter {

		/**
		 * @generated
		 */
		private final IElementType elementType;

		/**
		 * @generated
		 */
		public HintAdapter(IElementType type, EObject object, String parserHint) {
			super(object, parserHint);
			assert type != null;
			elementType = type;
		}

		/**
		 * @generated
		 */
		public Object getAdapter(Class adapter) {
			if (IElementType.class.equals(adapter)) {
				return elementType;
			}
			return super.getAdapter(adapter);
		}
	}

}
